feat: Make Sonnet 4.6 free for one week in review mode#295
feat: Make Sonnet 4.6 free for one week in review mode#295kiloconnect[bot] wants to merge 10 commits intomainfrom
Conversation
- Add claude-sonnet-4-6-20250514 as a free promotional model for Code Reviewer - Promotion window: 2026-02-18 to 2026-02-25 (7 days) - Model is hidden from public model list (review_only flag) - Only accessible through internal API (Code Reviewer) during promotion - Add promotion tracking admin endpoint (getReviewPromotionStats) - Add structured logging for promotion model usage
| */ | ||
| export function getDefaultCodeReviewModel(): string { | ||
| const promoModel = getActiveReviewPromotionModel(); | ||
| return promoModel?.internal_id ?? BASE_CODE_REVIEW_MODEL; |
There was a problem hiding this comment.
CRITICAL: getDefaultCodeReviewModel() returns internal_id instead of public_id, which means the promotional model will not be recognized as free by the API route.
The API route at src/app/api/openrouter/[...path]/route.ts uses the model ID to check isFreeModel(), isReviewOnlyModel(), and isRateLimitedModel() — all of which match against public_id. The applyProviderSpecificLogic() function in src/lib/providers/index.ts:243 then rewrites requestToMutate.model from public_id → internal_id before sending to OpenRouter.
By returning internal_id here, the model bypasses the review-only access gate and isn't recognized as free, so users will be charged credits for what's supposed to be a free promotional model.
For reference, the Slack integration correctly uses public_id (opus_46_free_slackbot_model.public_id) in src/lib/integrations/slack-service.ts:20.
| return promoModel?.internal_id ?? BASE_CODE_REVIEW_MODEL; | |
| return promoModel?.public_id ?? BASE_CODE_REVIEW_MODEL; |
There was a problem hiding this comment.
this comment is valid, isn't it?
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
WARNING
SUGGESTION
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (9 files)
|
Use leftJoin instead of innerJoin for cli_sessions to avoid dropping reviews without a session. Fix COALESCE type mismatch, default empty stats result, exclude review_only models from rate limiting, and remove deprecated DEFAULT_CODE_REVIEW_MODEL constant.
…g/cloud into feat/sonnet-46-free-review-promo
| display_name: 'Anthropic: Claude Sonnet 4.6 (Free for Code Reviewer)', | ||
| description: 'Claude Sonnet 4.6 — free for one week in Code Reviewer (review mode)', | ||
| context_length: 1_000_000, | ||
| max_completion_tokens: 16384, |
There was a problem hiding this comment.
| max_completion_tokens: 16384, | |
| max_completion_tokens: 128000, |
| export const sonnet_46_free_review_model = { | ||
| public_id: SONNET_46_REVIEW_PROMO_MODEL_ID, | ||
| display_name: 'Anthropic: Claude Sonnet 4.6 (Free for Code Reviewer)', | ||
| description: 'Claude Sonnet 4.6 — free for one week in Code Reviewer (review mode)', |
There was a problem hiding this comment.
What does (review mode) add to this description? i don't think users can actually use this model for review model locally, right?
| promotion_start: '2026-02-18T11:00:00Z', // 6 AM East Coast | ||
| promotion_end: '2026-02-25T11:00:00Z', |
There was a problem hiding this comment.
Instead of adding these two new fields, I'd just use: is_enabled: current_time < promotion_end
There was a problem hiding this comment.
That way you also don't need to have a isReviewPromotionActive because then the promotion is active as long as model.is_enabled is true
| }), | ||
|
|
||
| // Sonnet 4.6 free review promotion tracking | ||
| getReviewPromotionStats: adminProcedure.query(async () => { |
There was a problem hiding this comment.
Is this just an orphaned procedure that you plan to use later?
| flags: ['reasoning', 'prompt_cache', 'vision'], | ||
| gateway: 'openrouter', | ||
| internal_id: 'anthropic/claude-sonnet-4.6', | ||
| inference_providers: ['anthropic'], |
There was a problem hiding this comment.
| inference_providers: ['anthropic'], | |
| inference_providers: [], |
for openrouter models this is only necessary if you want to constrain which provider is used.
| .concat(kiloFreeModels.filter(m => m.is_enabled).map(model => convertFromKiloModel(model))) | ||
| .concat( | ||
| kiloFreeModels | ||
| .filter(m => m.is_enabled && !m.allowed_uses?.length) |
There was a problem hiding this comment.
with this change I don't think it will be possible for users to switch back to the free promotional model after switching to another model, unless this PR is also finished: #149
| */ | ||
| export const DEFAULT_CODE_REVIEW_MODEL = 'anthropic/claude-sonnet-4.5'; | ||
| export function getDefaultCodeReviewModel(): string { | ||
| const promoModel = getActiveReviewPromotionModel(); |
There was a problem hiding this comment.
when the promo ends, what is the expecte experience for existing users? will the get an error or will they silently be moved to the paid model? if the latter, then you don't actually need to add a custom model slug and it would suffice to override the cost administration
| * If a review-only promotional model is currently active, it takes precedence. | ||
| */ | ||
| export const DEFAULT_CODE_REVIEW_MODEL = 'anthropic/claude-sonnet-4.5'; | ||
| export function getDefaultCodeReviewModel(): string { |
There was a problem hiding this comment.
I don't think this belongs here, and we want to restrict this file to only the constants
There was a problem hiding this comment.
(this file was only ever meant for ENV vars which dont need to be ENV vars)
Summary
Make Claude Sonnet 4.6 free for one week in Code Reviewer (review mode).
Promotion window: 2026-02-18 11:00 UTC → 2026-02-25 11:00 UTC (7 days)
Changes
Free model promotion (following PR #27 patterns)
sonnet_46_free_review_modelinsrc/lib/providers/anthropic.tswithreview_only: trueflagKiloFreeModeltype withreview_only,promotion_start, andpromotion_endfieldskiloFreeModelsarray insrc/lib/models.tsslackbot_only)Promotion-aware model selection
getDefaultCodeReviewModel()function that returns the promotional model during the active windowprepare-review-payload.tsto use the promotion-aware model selectionTracking & Reporting
getReviewPromotionStatstRPC query in the admin code reviews router that reports:Access control
internalApiUse)promotion_end, the model returns "does not exist"skipBalanceCheck: trueTesting
Built for alex.alecu by Kilo for Slack